<!DOCTYPE html>



  


<html class="theme-next pisces use-motion" lang="">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta name="description" content="####1. 格式解析 ######1). AndroidManifest.xml文件格式看雪大神–原图地址">
<meta name="keywords" content="Android、iOS、Web、React Native">
<meta property="og:type" content="article">
<meta property="og:title" content="Android-解析AndroidManifest-xml文件">
<meta property="og:url" content="http://yoursite.com/blog/2018/08/06/Android-Plugin/Android-解析AndroidManifest-xml文件/index.html">
<meta property="og:site_name" content="凌浩雨_博客">
<meta property="og:description" content="####1. 格式解析 ######1). AndroidManifest.xml文件格式看雪大神–原图地址">
<meta property="og:locale" content="default">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-b78818af0971422a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="https://upload-images.jianshu.io/upload_images/3110861-e092ae645c3c3d55.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:updated_time" content="2018-08-06T11:11:01.218Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="Android-解析AndroidManifest-xml文件">
<meta name="twitter:description" content="####1. 格式解析 ######1). AndroidManifest.xml文件格式看雪大神–原图地址">
<meta name="twitter:image" content="https://upload-images.jianshu.io/upload_images/3110861-b78818af0971422a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Pisces',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: 'Author'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://yoursite.com/blog/2018/08/06/Android-Plugin/Android-解析AndroidManifest-xml文件/"/>





  <title>Android-解析AndroidManifest-xml文件 | 凌浩雨_博客</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="default">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">凌浩雨_博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            Home
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            Archives
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://yoursite.com/blog/blog/2018/08/06/Android-Plugin/Android-解析AndroidManifest-xml文件/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="凌浩雨">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.jpeg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="凌浩雨_博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">Android-解析AndroidManifest-xml文件</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">Posted on</span>
              
              <time title="Post created" itemprop="dateCreated datePublished" datetime="2018-08-06T18:01:38+08:00">
                2018-08-06
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <p>####1. 格式解析</p>
<p>######1). AndroidManifest.xml文件格式<br><a href="https://bbs.pediy.com/thread-194206.htm" target="_blank" rel="noopener">看雪大神–原图地址</a><br><img src="https://upload-images.jianshu.io/upload_images/3110861-b78818af0971422a.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图1.png"></p>
<a id="more"></a>
<p>图中可以清晰的看出AndroidManifest.xml文件的格式，几个大的模块：</p>
<ul>
<li>Magic Number 魔数</li>
<li>File Size 文件大小</li>
<li>String Chunk 字符串模块</li>
<li>ResourceId Chunk 资源模块</li>
<li>XmlContent Chunk XML模块<br>######2). 解析–主流程<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line">public class ParseMain &#123;</span><br><span class="line">	/**</span><br><span class="line">	 * 应用主入口</span><br><span class="line">	 */</span><br><span class="line">	public static void main(String[] args) &#123;</span><br><span class="line">		// 读取AndroidManifest.xml文件为二进制数据</span><br><span class="line">		byte[] byteSrc = Util.readXML(&quot;xml/AndroidManifest.xml&quot;);</span><br><span class="line">		// 解析XML 头</span><br><span class="line">		System.out.println(&quot;Parse XML Header -----------&quot;);</span><br><span class="line">		ParseChunkUtil.parseXmlHeader(byteSrc);</span><br><span class="line">		System.out.println();</span><br><span class="line">		// 解析String Chunk</span><br><span class="line">		System.out.println(&quot;Parse String Chunk -----------&quot;);</span><br><span class="line">		ParseChunkUtil.parseStringChunk(byteSrc);</span><br><span class="line">		System.out.println();</span><br><span class="line">		// 解析Resource Chunk</span><br><span class="line">		System.out.println(&quot;Parse Resource Chunk -----------&quot;);</span><br><span class="line">		ParseChunkUtil.parseResourceChunk(byteSrc);</span><br><span class="line">		System.out.println();</span><br><span class="line">		// 解析XML内容</span><br><span class="line">		System.out.println(&quot;Parse XML Content -----------&quot;);</span><br><span class="line">		ParseChunkUtil.parseXmlContent(byteSrc);</span><br><span class="line">		System.out.println();</span><br><span class="line">		// 输出XML文件</span><br><span class="line">		ParseChunkUtil.writeFormatXmlToFile();</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
<p>######3). 头部</p>
<ul>
<li>Magic Number 魔数：4个字节</li>
<li>File Size 文件大小：4个字节<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">/** XML文件内容 */</span><br><span class="line">private static StringBuilder builder = new StringBuilder();</span><br><span class="line">/**</span><br><span class="line"> * 解析xml的头部信息 </span><br><span class="line"> * 	1. Magic Number: 文件魔数，4个字节 </span><br><span class="line"> * 	2. File Size: 文件大小，4个字节</span><br><span class="line"> * </span><br><span class="line"> * @param byteSrc</span><br><span class="line"> */</span><br><span class="line">public static void parseXmlHeader(byte[] byteSrc) &#123;</span><br><span class="line">	// 1. Magic Number: 文件魔数，4个字节</span><br><span class="line">	byte[] magic = Util.copyByte(byteSrc, 0, 4);</span><br><span class="line">	System.out.println(&quot;magic number:&quot; + Util.byteToHexString(magic));</span><br><span class="line">	// 2. File Size: 文件大小，4个字节</span><br><span class="line">	byte[] size = Util.copyByte(byteSrc, 4, 4);</span><br><span class="line">	System.out.println(&quot;xml size:&quot; + Util.byteToHexString(size));</span><br><span class="line"></span><br><span class="line">	// 拼接文件内容</span><br><span class="line">	builder.append(&quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;utf-8\&quot;?&gt;&quot;);</span><br><span class="line">	builder.append(&quot;\n&quot;);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</li>
</ul>
<p>######4). String Chunk 解析<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br></pre></td><td class="code"><pre><span class="line">/** String Chunk 偏移量 */</span><br><span class="line">private static int STRING_CHUNK_OFFSET = 8;</span><br><span class="line">/** 字符串列表 */</span><br><span class="line">private static ArrayList&lt;String&gt; stringContentList;</span><br><span class="line">/** Resource Chunk 偏移量，动态计算 */</span><br><span class="line">private static int resourceChunkOffset;</span><br><span class="line">/**</span><br><span class="line"> * 解析String Chunk </span><br><span class="line"> * 	1. ChunkType：StringChunk的类型，固定四个字节：0x001C0001 </span><br><span class="line"> * 	2. ChunkSize：StringChunk的大小，四个字节 </span><br><span class="line"> * 	3. StringCount：StringChunk中字符串的个数，四个字节 </span><br><span class="line"> * 	4. StyleCount：StringChunk中样式的个数，四个字节，但是在实际解析过程中，这个值一直是0x00000000 </span><br><span class="line"> * 	5. Unknown：位置区域，四个字节，在解析的过程中，这里需要略过四个字节 </span><br><span class="line"> * 	6. StringPoolOffset：字符串池的偏移值，四个字节，这个偏移值是相对于StringChunk的头部位置 </span><br><span class="line"> * 	7. StylePoolOffset：样式池的偏移值，四个字节，这里没有Style,所以这个字段可忽略 </span><br><span class="line"> * 	8. StringOffsets：每个字符串的偏移值，所以他的大小应该是：StringCount*4个字节 </span><br><span class="line"> * 	9. SytleOffsets：每个样式的偏移值，所以他的大小应该是SytleCount*4个字节 </span><br><span class="line"> * 	10. String Pool </span><br><span class="line"> * 	11. Style Pool</span><br><span class="line"> * </span><br><span class="line"> * @param byteSrc 二进制数据</span><br><span class="line"> */</span><br><span class="line">public static void parseStringChunk(byte[] byteSrc) &#123;</span><br><span class="line">	// 1. Chunk Type：String Chunk的类型，固定四个字节：0x001C0001</span><br><span class="line">	byte[] type = Util.copyByte(byteSrc, STRING_CHUNK_OFFSET, 4);</span><br><span class="line">	System.out.println(&quot;string chunktag:&quot; + Util.byteToHexString(type));</span><br><span class="line"></span><br><span class="line">	// 2. Chunk Size：String Chunk的大小，四个字节</span><br><span class="line">	byte[] sizeByte = Util.copyByte(byteSrc, STRING_CHUNK_OFFSET + 4, 4);</span><br><span class="line">	// 获取String Chunk大小</span><br><span class="line">	int chunkSize = Util.byte2Int(sizeByte);</span><br><span class="line">	System.out.println(&quot;chunk size:&quot; + chunkSize);</span><br><span class="line"></span><br><span class="line">	// 3. String Count：StringChunk中字符串的个数，四个字节</span><br><span class="line">	byte[] stringCountByte = Util.copyByte(byteSrc, STRING_CHUNK_OFFSET + 8, 4);</span><br><span class="line">	// 获取字符串个数</span><br><span class="line">	int chunkStringCount = Util.byte2Int(stringCountByte);</span><br><span class="line">	System.out.println(&quot;string count:&quot; + chunkStringCount);</span><br><span class="line"></span><br><span class="line">	// 4. Style Count：StringChunk中样式的个数，四个字节，但是在实际解析过程中，这个值一直是0x00000000</span><br><span class="line">	// 5. Unknown：位置区域，四个字节，在解析的过程中，这里需要略过四个字节</span><br><span class="line">	// 6. String Pool Offset：字符串池的偏移值，四个字节，这个偏移值是相对于StringChunk的头部位置</span><br><span class="line">	// 创建指定字符串个数的列表</span><br><span class="line">	stringContentList = new ArrayList&lt;String&gt;(chunkStringCount);</span><br><span class="line">	// 7. Style Pool Offset：样式池的偏移值，四个字节，这里没有Style,所以这个字段可忽略</span><br><span class="line">	// 8. String Offsets：每个字符串的偏移值，所以他的大小应该是：StringCount*4个字节</span><br><span class="line">	byte[] stringOffsetByte = Util.copyByte(byteSrc, 28, 4);</span><br><span class="line">	// 获取字符串内容开始位置</span><br><span class="line">	int stringContentStart = 8 + Util.byte2Int(stringOffsetByte);</span><br><span class="line">	System.out.println(&quot;start:&quot; + stringContentStart);</span><br><span class="line">	// 9. Sytle Offsets：每个样式的偏移值，所以他的大小应该是SytleCount*4个字节</span><br><span class="line">	// 10. String Pool</span><br><span class="line">	// 获取String Content</span><br><span class="line">	byte[] stringContentByte = Util.copyByte(byteSrc, stringContentStart, chunkSize);</span><br><span class="line">	// 获取内容开始位置, 字符串大小</span><br><span class="line">	int start = 0, stringSize;</span><br><span class="line">	// 字符串</span><br><span class="line">	String text = &quot;&quot;;</span><br><span class="line">	// 循环结束条件，字符串列表中的数据个数等于字符串个数</span><br><span class="line">	while (stringContentList.size() &lt; chunkStringCount) &#123;</span><br><span class="line">		// 解析字符串时问题，编码：UTF-8和UTF-16,如果是UTF-8的话是以00结尾的，如果是UTF-16的话以00 00结尾的</span><br><span class="line">		// 格式是：偏移值开始的两个字节是字符串的长度，接着是字符串的内容，后面跟着两个字符串的结束符00</span><br><span class="line">		// 一个字符对应两个字节，所以要乘以2</span><br><span class="line">		stringSize = Util.byte2Short(Util.copyByte(stringContentByte, start, 2)) * 2;</span><br><span class="line">		System.out.println(&quot;string size : &quot; + stringSize);</span><br><span class="line">		// 获取字符串文本</span><br><span class="line">		text = new String(Util.copyByte(stringContentByte, start + 2, stringSize + 2));</span><br><span class="line">		System.out.println(&quot;text : &quot; + Util.filterStringNull(text));</span><br><span class="line">		// 字符串文本</span><br><span class="line">		stringContentList.add(Util.filterStringNull(text));</span><br><span class="line">		start += (2 + stringSize + 2);</span><br><span class="line">	&#125;</span><br><span class="line">	// 11. Style Pool</span><br><span class="line"></span><br><span class="line">	// 此处的代码是用来解析资源文件xml的</span><br><span class="line">	/*int index = 0; </span><br><span class="line">	while(index &lt; chunkStringCount)&#123;</span><br><span class="line">		byte[] stringSizeByte = Util.copyByte(stringContentByte, start, 2);</span><br><span class="line">		stringSize = (stringSizeByte[1] &amp; 0x7F);</span><br><span class="line">		System.out.println(&quot;string size:&quot;+Util.byteToHexString(Util.int2Byte(stringSize)));</span><br><span class="line">		if(stringSize != 0)&#123; //这里注意是UTF-8编码的 String</span><br><span class="line">			text = &quot;&quot;; </span><br><span class="line">			try&#123; </span><br><span class="line">				text = new String(Util.copyByte(stringContentByte, start + 2,stringSize), &quot;utf-8&quot;); </span><br><span class="line">			&#125;catch(Exception e)&#123;</span><br><span class="line">				System.out.println(&quot;string encode error:&quot;+e.toString());</span><br><span class="line">			&#125;</span><br><span class="line">			stringContentList.add(text); </span><br><span class="line">		&#125; else &#123; </span><br><span class="line">			stringContentList.add(&quot;&quot;);</span><br><span class="line">		&#125;</span><br><span class="line">		start += (stringSize+3);</span><br><span class="line">		index++;</span><br><span class="line">	&#125;</span><br><span class="line">	 */</span><br><span class="line">	// 拼接Resource Chunk 偏移位置</span><br><span class="line">	resourceChunkOffset = STRING_CHUNK_OFFSET + Util.byte2Int(sizeByte);</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>######5). Resource Chunk 解析<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line">/** XMLContent Chunk 偏移量，动态计算 */</span><br><span class="line">private static int nextChunkOffset;</span><br><span class="line">/**</span><br><span class="line"> * 解析Resource Chunk 1. Chunk Type: Resource Chunk 类型，4个字节，0x00080108 2.</span><br><span class="line"> * Chunk Size: Resource Chunk 大小，4个字节 3. ResourceIds: 资源ID,</span><br><span class="line"> * 大小是ResourceChunk大小除以4，减去头部的大小8个字节(ChunkType和ChunkSize)==(Chunk Size / 4 -</span><br><span class="line"> * 2) * 4个字节</span><br><span class="line"> * </span><br><span class="line"> * @param byteSrc</span><br><span class="line"> *            二进制数据</span><br><span class="line"> */</span><br><span class="line">public static void parseResourceChunk(byte[] byteSrc) &#123;</span><br><span class="line">	// 1. Chunk Type: Resource Chunk 类型，4个字节，0x00080108</span><br><span class="line">	byte[] typeByte = Util.copyByte(byteSrc, resourceChunkOffset, 4);</span><br><span class="line">	System.out.println(&quot;type: &quot; + Util.byteToHexString(typeByte));</span><br><span class="line">	// 2. Chunk Size: Resource Chunk 大小，4个字节</span><br><span class="line">	byte[] sizeByte = Util.copyByte(byteSrc, resourceChunkOffset + 4, 4);</span><br><span class="line">	// 文件大小</span><br><span class="line">	int size = Util.byte2Int(sizeByte);</span><br><span class="line">	System.out.println(&quot;size: &quot; + size);</span><br><span class="line">	// 3. ResourceIds: 资源ID,</span><br><span class="line">	// 大小是ResourceChunk大小除以4，减去头部的大小8个字节(ChunkType和ChunkSize)==(Chunk Size /</span><br><span class="line">	// 4 - 2) * 4个字节</span><br><span class="line">	// chunk size包含chunk type 与 chunk size两个数组的字节，所以要剔除</span><br><span class="line">	byte[] resourceIdByte = Util.copyByte(byteSrc, resourceChunkOffset + 8, size - 8);</span><br><span class="line">	// 创建资源列表</span><br><span class="line">	ArrayList&lt;Integer&gt; resourceIdList = new ArrayList&lt;&gt;(resourceIdByte.length / 4);</span><br><span class="line">	// 遍历获取资源ID</span><br><span class="line">	for (int i = 0; i &lt; resourceIdByte.length; i += 4) &#123;</span><br><span class="line">		// 获取资源ID</span><br><span class="line">		int resId = Util.byte2Int(Util.copyByte(resourceIdByte, i, 4));</span><br><span class="line">		System.out.println(&quot;id: &quot; + resId + &quot;, hex: &quot; + Util.byteToHexString(Util.copyByte(resourceIdByte, i, 4)));</span><br><span class="line">		// 将资源ID添加到列表</span><br><span class="line">		resourceIdList.add(resId);</span><br><span class="line">	&#125;</span><br><span class="line">	// 计算XMLContent Chunk 偏移量</span><br><span class="line">	nextChunkOffset = resourceChunkOffset + size;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>######6). XmlContent Chunk解析<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br></pre></td><td class="code"><pre><span class="line">/**KEY为uri,VALUE为prefix的map*/</span><br><span class="line">private static Map&lt;String,String&gt; uriPrefixMap = new HashMap&lt;&gt;();</span><br><span class="line">/**KEY为prefix,VALUE为uri的map*/</span><br><span class="line">private static Map&lt;String, String&gt; prefixUriMap = new HashMap&lt;&gt;();</span><br><span class="line">/**</span><br><span class="line"> * 开始解析XML的正文内容 </span><br><span class="line"> * 	1. type: 类型，4个字节 </span><br><span class="line"> * 	2. size: 文件大小，4个字节 </span><br><span class="line"> * 	3. start namaspace </span><br><span class="line"> * 	4. start tag </span><br><span class="line"> * 	5. end tag </span><br><span class="line"> * 	6. end namespace</span><br><span class="line"> * </span><br><span class="line"> * @param byteSrc 二进制数据</span><br><span class="line"> */</span><br><span class="line">public static void parseXmlContent(byte[] byteSrc) &#123;</span><br><span class="line">	// 判断是否到结尾处了</span><br><span class="line">	while (!isEnd(byteSrc.length)) &#123;</span><br><span class="line">		// 获取类型</span><br><span class="line">		byte[] typeByte = Util.copyByte(byteSrc, nextChunkOffset, 4);</span><br><span class="line">		// 获取节点类型</span><br><span class="line">		int type = Util.byte2Int(typeByte);</span><br><span class="line">		System.out.println(&quot;chunk type: &quot; + Util.byteToHexString(typeByte));</span><br><span class="line">		// 文件大小</span><br><span class="line">		byte[] sizeByte = Util.copyByte(byteSrc, nextChunkOffset + 4, 4);</span><br><span class="line">		// 获取文件大小</span><br><span class="line">		int size = Util.byte2Int(sizeByte);</span><br><span class="line">		System.out.println(&quot;size: &quot; + size);</span><br><span class="line">		switch (type) &#123;</span><br><span class="line">			case ChunkMagicNumber.CHUNK_START_NS:</span><br><span class="line">				System.out.println(&quot;parse start namespace&quot;);</span><br><span class="line">				parseStartNameSpaceChunk(Util.copyByte(byteSrc, nextChunkOffset, size));</span><br><span class="line">				break;</span><br><span class="line">			case ChunkMagicNumber.CHUNK_START_TAG:</span><br><span class="line">				System.out.println(&quot;parse start tag&quot;);</span><br><span class="line">				parseStartTagChunk(Util.copyByte(byteSrc, nextChunkOffset, size));</span><br><span class="line">				break;</span><br><span class="line">			case ChunkMagicNumber.CHUNK_END_TAG:</span><br><span class="line">				System.out.println(&quot;parse end tag&quot;);</span><br><span class="line">				parseEndTagChunk(Util.copyByte(byteSrc, nextChunkOffset, size));</span><br><span class="line">				break;</span><br><span class="line">			case ChunkMagicNumber.CHUNK_END_NS:</span><br><span class="line">				System.out.println(&quot;parse end namespace&quot;);</span><br><span class="line">				parseEndNameSpaceChunk(Util.copyByte(byteSrc, nextChunkOffset, size));</span><br><span class="line">				break;</span><br><span class="line">			default:</span><br><span class="line">				break;</span><br><span class="line">		&#125;</span><br><span class="line">		// 赋值</span><br><span class="line">		nextChunkOffset += size;</span><br><span class="line">	&#125;</span><br><span class="line">	System.out.println(&quot;parse xml: &quot; + builder.toString());</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>######7). Start Namespace Chunk解析<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * 解析命名空间 开始</span><br><span class="line"> * 	1. Chunk Type：类型，4个字节</span><br><span class="line"> * 	2. Chunk Size: 大小，4个字节</span><br><span class="line"> * 	3. Line Number: 在AndroidManifest.xml文件中的行号，4个字节</span><br><span class="line"> * 	4. Unkonwn(0xFFFFFFFF): 未知区域，4个字节</span><br><span class="line"> * 	5. Prefix: 命名空间前缀，4个字节。如：android</span><br><span class="line"> * 	6. Uri: 命令空间的Uri。如：http://schemas.android.com/apk/res/android</span><br><span class="line"> * @param byteSrc 字节数组</span><br><span class="line"> */</span><br><span class="line">private static void parseStartNameSpaceChunk(byte[] byteSrc) &#123;</span><br><span class="line">	// 1. Chunk Type：类型，4个字节</span><br><span class="line">	byte[] typeByte = Util.copyByte(byteSrc, 0, 4);</span><br><span class="line">	System.out.println(&quot;type: &quot; + Util.byteToHexString(typeByte));</span><br><span class="line">	// 2. Chunk Size: 大小，4个字节</span><br><span class="line">	byte[] sizeByte = Util.copyByte(byteSrc, 4, 4);</span><br><span class="line">	// 获取大小</span><br><span class="line">	int size = Util.byte2Int(sizeByte);</span><br><span class="line">	System.out.println(&quot;size: &quot; + size);</span><br><span class="line">	// 3. Line Number: 在AndroidManifest.xml文件中的行号，4个字节</span><br><span class="line">	byte[] lineNumberByte = Util.copyByte(byteSrc, 8, 4);</span><br><span class="line">	// 获取行号</span><br><span class="line">	int lineNumber = Util.byte2Int(lineNumberByte);</span><br><span class="line">	System.out.println(&quot;line number: &quot; + lineNumber);</span><br><span class="line">	// 4. Unkonwn(0xFFFFFFFF): 未知区域，4个字节</span><br><span class="line">	// 5. Prefix: 命名空间前缀，4个字节。如：android</span><br><span class="line">	byte[] prefixByte = Util.copyByte(byteSrc, 16, 4);</span><br><span class="line">	// 获取前缀标识</span><br><span class="line">	int prefixIndex = Util.byte2Int(prefixByte);</span><br><span class="line">	// 获取前缀</span><br><span class="line">	String prefix = stringContentList.get(prefixIndex);</span><br><span class="line">	System.out.println(&quot;prefix: &quot; + prefixIndex + &quot;, prefix str: &quot; + prefix);</span><br><span class="line">	// 6. Uri: 命令空间的Uri。如：http://schemas.android.com/apk/res/android</span><br><span class="line">	byte[] uriByte = Util.copyByte(byteSrc, 20, 4);</span><br><span class="line">	// 获取uri标识</span><br><span class="line">	int uriIndex = Util.byte2Int(uriByte);</span><br><span class="line">	// 获取uri</span><br><span class="line">	String uri = stringContentList.get(uriIndex);</span><br><span class="line">	System.out.println(&quot;uri: &quot; + uriIndex + &quot;, uri str: &quot; + uri);</span><br><span class="line">	</span><br><span class="line">	// 存入Map</span><br><span class="line">	uriPrefixMap.put(uri, prefix);</span><br><span class="line">	prefixUriMap.put(prefix, uri);		</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>######8). Start Tag Chunk 解析<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * 解析TAG 开始</span><br><span class="line"> * 	1. Chunk Type: 类型，4个字节：0x00100102</span><br><span class="line"> * 	2. Chunk Size: 大小，4个字节</span><br><span class="line"> * 	3. Line Number: AndroidManifesta.xml文件中的行号，4个字节</span><br><span class="line"> * 	4. Unknown: 未知区域，4个字节</span><br><span class="line"> * 	5. NamespaceUri: 标签用到的命名空间的Uri,比如用到了android这个前缀，那么就需要用http://schemas.android.com/apk/res/android这个Uri去获取，四个字节</span><br><span class="line"> * 	6. Name: 标签名称（字符串中的索引值），4个字节</span><br><span class="line"> * 	7. Flags: 标签的类型，4个字节，开始/结束</span><br><span class="line"> * 	8. AttributeCount: 标签包含的属性个数，4个字节</span><br><span class="line"> * 	9. ClassAttribute: 标签包含的属性，4个字节</span><br><span class="line"> * 	10. Attributes: 属性内容，每个属性算是一个Entry，固定大小为5的字节数组</span><br><span class="line"> * 	[Namespace，Uri，Name，ValueString，Data]，我们在解析的时候需要注意第四个值，要做一次处理：需要右移24位。所以这个字段的大小是：属性个数*5*4个字节</span><br><span class="line"> * @param byteSrc 字节数组</span><br><span class="line"> */</span><br><span class="line">private static void parseStartTagChunk(byte[] byteSrc) &#123;</span><br><span class="line">	// 1. Chunk Type: 类型，4个字节：0x00100102</span><br><span class="line">	byte[] typeByte = Util.copyByte(byteSrc, 0, 4);</span><br><span class="line">	System.out.println(&quot;type: &quot; + Util.byteToHexString(typeByte));</span><br><span class="line">	// 2. Chunk Size: 大小，4个字节</span><br><span class="line">	byte[] sizeByte = Util.copyByte(byteSrc, 4, 4);</span><br><span class="line">	// 获取大小</span><br><span class="line">	int size = Util.byte2Int(sizeByte);</span><br><span class="line">	System.out.println(&quot;size: &quot; + size);</span><br><span class="line">	// 3. Line Number: AndroidManifesta.xml文件中的行号，4个字节</span><br><span class="line">	byte[] lineNumberByte = Util.copyByte(byteSrc, 8, 4);</span><br><span class="line">	// 获取行号</span><br><span class="line">	int lineNumber = Util.byte2Int(lineNumberByte);</span><br><span class="line">	System.out.println(&quot;line number: &quot; + lineNumber);</span><br><span class="line">	// 4. Unknown: 未知区域，4个字节</span><br><span class="line">	byte[] prefixByte = Util.copyByte(byteSrc, 8, 4);</span><br><span class="line">	// 获取前缀标识</span><br><span class="line">	int prefixIndex = Util.byte2Int(prefixByte);</span><br><span class="line">	// 这里可能会返回-1, 如果返回-1的话，那就说明没有前缀</span><br><span class="line">	if (-1 != prefixIndex &amp;&amp; prefixIndex &lt; stringContentList.size()) &#123;</span><br><span class="line">		System.out.println(&quot;prefix: &quot; + prefixIndex);</span><br><span class="line">		System.out.println(&quot;prefix str: &quot; + stringContentList.get(prefixIndex));</span><br><span class="line">	&#125; else &#123;</span><br><span class="line">		System.out.println(&quot;prefix null&quot;);</span><br><span class="line">	&#125;</span><br><span class="line">	// 5. NamespaceUri: 标签用到的命名空间的Uri,比如用到了android这个前缀，那么就需要用http://schemas.android.com/apk/res/android这个Uri去获取，四个字节</span><br><span class="line">	byte[] uriByte = Util.copyByte(byteSrc, 16, 4);</span><br><span class="line">	// 获取uri标识</span><br><span class="line">	int uriIndex = Util.byte2Int(uriByte);</span><br><span class="line">	// 如果前缀大的话，说明uri不存在</span><br><span class="line">	if (-1 != uriIndex &amp;&amp; prefixIndex &lt; stringContentList.size()) &#123;</span><br><span class="line">		System.out.println(&quot;uri: &quot; + uriIndex);</span><br><span class="line">		System.out.println(&quot;uri str: &quot; + stringContentList.get(uriIndex));</span><br><span class="line">	&#125; else &#123;</span><br><span class="line">		System.out.println(&quot;uri null&quot;);</span><br><span class="line">	&#125;</span><br><span class="line">	// 6. Name: 标签名称（字符串中的索引值），4个字节</span><br><span class="line">	byte[] tagNameByte = Util.copyByte(byteSrc, 20, 4);</span><br><span class="line">	System.out.println(Util.byteToHexString(tagNameByte));</span><br><span class="line">	// 获取标签名称标识</span><br><span class="line">	int nameIndex = Util.byte2Int(tagNameByte);</span><br><span class="line">	// 获取标签名称</span><br><span class="line">	String name = stringContentList.get(nameIndex);</span><br><span class="line">	if (-1 != nameIndex) &#123;</span><br><span class="line">		System.out.println(&quot;tag name index: &quot; + nameIndex);</span><br><span class="line">		System.out.println(&quot;tag name str: &quot; + name);</span><br><span class="line">	&#125; else &#123;</span><br><span class="line">		System.out.println(&quot;tag name null&quot;);</span><br><span class="line">	&#125;</span><br><span class="line">	// 7. Flags: 标签的类型，4个字节，开始/结束</span><br><span class="line">	// 8. AttributeCount: 标签包含的属性个数，4个字节</span><br><span class="line">	byte[] attrCountByte = Util.copyByte(byteSrc, 28, 4);</span><br><span class="line">	// 获取属性个数</span><br><span class="line">	int attrCount = Util.byte2Int(attrCountByte);</span><br><span class="line">	System.out.println(&quot;attr count:&quot; + attrCount);</span><br><span class="line">	// 9. ClassAttribute: 标签包含的属性，4个字节</span><br><span class="line">	// 10. Attributes: 属性内容，每个属性算是一个Entry，固定大小为5的字节数组</span><br><span class="line">	// 创建指定长度的属性列表</span><br><span class="line">	ArrayList&lt;AttributeData&gt; attrList = new ArrayList&lt;&gt;(attrCount);</span><br><span class="line">	// 遍历</span><br><span class="line">	for (int i = 0; i &lt; attrCount; i++) &#123;</span><br><span class="line">		// 五个属性</span><br><span class="line">		Integer[] values = new Integer[5];</span><br><span class="line">		// 创建属性对象</span><br><span class="line">		AttributeData attData = new AttributeData();</span><br><span class="line">		// 遍历赋值</span><br><span class="line">		for (int j = 0; j &lt; 5; j++) &#123;</span><br><span class="line">			// 5个属性，每个属性占4个字节，所以是i*5*4</span><br><span class="line">			int value = Util.byte2Int(Util.copyByte(byteSrc, 36 + i * 5 * 4 + j * 4, 4));</span><br><span class="line">			switch (j) &#123;</span><br><span class="line">			case 0:</span><br><span class="line">				attData.nameSpaceUri = value;</span><br><span class="line">				break;</span><br><span class="line">			case 1:</span><br><span class="line">				attData.name = value;</span><br><span class="line">				break;</span><br><span class="line">			case 2:</span><br><span class="line">				attData.valueString = value;</span><br><span class="line">				break;</span><br><span class="line">			case 3:</span><br><span class="line">				// 获取到的type要右移24位</span><br><span class="line">				attData.type = (value &gt;&gt; 24);					</span><br><span class="line">				break;</span><br><span class="line">			case 4:</span><br><span class="line">				attData.data = value;</span><br><span class="line">				break;</span><br><span class="line">			default:</span><br><span class="line">				break;</span><br><span class="line">			&#125;</span><br><span class="line">			values[j] = value;</span><br><span class="line">		&#125;</span><br><span class="line">		// 添加到属性列表</span><br><span class="line">		attrList.add(attData);</span><br><span class="line">	&#125;</span><br><span class="line">	// 构造XML结构</span><br><span class="line">	builder.append(createStartTagXml(name, attrList));</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>######9). End Tag Chunk解析<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br></pre></td><td class="code"><pre><span class="line">/**</span><br><span class="line"> * 解析TAG 结束</span><br><span class="line"> * 	1. Chunk Type(0x00100101): 4个字节</span><br><span class="line"> * 	2. Chunk Size: 4个字节</span><br><span class="line"> * 	3. Line Number: 4个字节</span><br><span class="line"> * 	4. Unknown(0xFFFFFFFF):4个字节</span><br><span class="line"> * 	5. Name: 4个字节</span><br><span class="line"> * 	6. Unknown: 4个字节</span><br><span class="line"> * 	7. Unknown: 4个字节</span><br><span class="line"> * @param byteSrc 字节数组</span><br><span class="line"> */</span><br><span class="line">private static void parseEndTagChunk(byte[] byteSrc) &#123;</span><br><span class="line">	// 1. Chunk Type(0x00100101): 4个字节</span><br><span class="line">	byte[] tyepByte = Util.copyByte(byteSrc, 0, 4);</span><br><span class="line">	System.out.println(&quot;type: &quot; + Util.byteToHexString(tyepByte));</span><br><span class="line">	// 2. Chunk Size: 4个字节</span><br><span class="line">	byte[] sizeByte = Util.copyByte(byteSrc, 4, 4);</span><br><span class="line">	// 获取长度</span><br><span class="line">	int size = Util.byte2Int(sizeByte);</span><br><span class="line">	System.out.println(&quot;size: &quot; + size);</span><br><span class="line">	// 3. Line Number: 4个字节</span><br><span class="line">	byte[] lineNumberByte = Util.copyByte(byteSrc, 8, 4);</span><br><span class="line">	// 获取行号</span><br><span class="line">	int lineNumber = Util.byte2Int(lineNumberByte);</span><br><span class="line">	System.out.println(&quot;line number:&quot; + lineNumber);</span><br><span class="line">	</span><br><span class="line">	// 解析prefix</span><br><span class="line">	byte[] prefixByte = Util.copyByte(byteSrc, 8, 4);</span><br><span class="line">	// 获取前缀标识</span><br><span class="line">	int prefixIndex = Util.byte2Int(prefixByte);</span><br><span class="line">	// 可能返回-1，如果返回-1，则说明没有prefix</span><br><span class="line">	if (-1 != prefixIndex &amp;&amp; prefixIndex &lt; stringContentList.size()) &#123;</span><br><span class="line">		System.out.println(&quot;prefix: &quot; + prefixIndex);</span><br><span class="line">		System.out.println(&quot;prefix str: &quot; + stringContentList.get(prefixIndex));</span><br><span class="line">	&#125; else &#123;</span><br><span class="line">		System.out.println(&quot;prefix null.&quot;);</span><br><span class="line">	&#125;</span><br><span class="line">	// 解析Uri</span><br><span class="line">	byte[] uriByte = Util.copyByte(byteSrc, 16, 4);</span><br><span class="line">	// 获取uri标识</span><br><span class="line">	int uriIndex = Util.byte2Int(uriByte);</span><br><span class="line">	// 如果前缀大的话，说明uri不存在</span><br><span class="line">	if (-1 != uriIndex &amp;&amp; prefixIndex &lt; stringContentList.size()) &#123;</span><br><span class="line">		System.out.println(&quot;uri: &quot; + uriIndex);</span><br><span class="line">		System.out.println(&quot;uri str: &quot; + stringContentList.get(uriIndex));</span><br><span class="line">	&#125; else &#123;</span><br><span class="line">		System.out.println(&quot;uri null&quot;);</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	// 4. Unknown(0xFFFFFFFF):4个字节</span><br><span class="line">	// 5. Name: 4个字节</span><br><span class="line">	byte[] tagNameByte = Util.copyByte(byteSrc, 20, 4);</span><br><span class="line">	System.out.println(&quot;name: &quot; + Util.byteToHexString(tagNameByte));</span><br><span class="line">	// 获取tag名标识</span><br><span class="line">	int tagNameIndex = Util.byte2Int(tagNameByte);</span><br><span class="line">	// 获取tag名</span><br><span class="line">	String tagName = stringContentList.get(tagNameIndex);</span><br><span class="line">	if (-1 != tagNameIndex) &#123;</span><br><span class="line">		System.out.println(&quot;tag name index: &quot; + tagNameIndex);</span><br><span class="line">		System.out.println(&quot;tag name str: &quot; + tagName);</span><br><span class="line">	&#125; else &#123;</span><br><span class="line">		System.out.println(&quot;tag name null&quot;);</span><br><span class="line">	&#125;</span><br><span class="line">		</span><br><span class="line">	builder.append(createEndTagXml(tagName));</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>######10). <a href="">源码下载</a></p>
<p>####2. <a href="https://code.google.com/archive/p/xml-apk-parser/" target="_blank" rel="noopener">xml-apk-parser解析</a></p>
<p>######1). 引包<br><img src="https://upload-images.jianshu.io/upload_images/3110861-e092ae645c3c3d55.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt="图2.png"></p>
<p>######2). 使用<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br></pre></td><td class="code"><pre><span class="line">public class APKParserDemo &#123;</span><br><span class="line">	/**指定要解析的文件*/</span><br><span class="line">	private static final String DEFAULT_XML = &quot;AndroidManifest.xml&quot;;</span><br><span class="line">	public static void main(String[] args) &#123;</span><br><span class="line">		String apkPath = &quot;xml/source.apk&quot;;</span><br><span class="line">		String content = getManifestXMLFromAPK(apkPath);</span><br><span class="line">		writeFormatXmlToFile(content);</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	/**</span><br><span class="line">	 * 获取AndroidManifest.xml文件</span><br><span class="line">	 * @param apkPath apk路径</span><br><span class="line">	 */</span><br><span class="line">	private static String getManifestXMLFromAPK(String apkPath) &#123;</span><br><span class="line">		ZipFile zipFile = null;</span><br><span class="line">		StringBuilder xmlBuilder = new StringBuilder();</span><br><span class="line">		try &#123;</span><br><span class="line">			// apk文件</span><br><span class="line">			File apkFile = new File(apkPath);</span><br><span class="line">			// 获取压缩文件</span><br><span class="line">			zipFile = new ZipFile(apkFile, ZipFile.OPEN_READ);</span><br><span class="line">			// 获取指定文件</span><br><span class="line">			ZipEntry entry = zipFile.getEntry(DEFAULT_XML);</span><br><span class="line">			</span><br><span class="line">			// 创建XML文件资源解析器</span><br><span class="line">			AXmlResourceParser parser = new AXmlResourceParser();</span><br><span class="line">			// 打开文件</span><br><span class="line">			parser.open(zipFile.getInputStream(entry));</span><br><span class="line">			</span><br><span class="line">			StringBuilder sb = new StringBuilder();</span><br><span class="line">			final String indentStep = &quot;	&quot;;</span><br><span class="line">			int type;</span><br><span class="line">			while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) &#123;</span><br><span class="line">				switch (type) &#123;</span><br><span class="line">				case XmlPullParser.START_DOCUMENT:</span><br><span class="line">					log(xmlBuilder, &quot;&lt;?xml version=\&quot;1.0\&quot; encoding=\&quot;utf-8\&quot;?&gt;&quot;);</span><br><span class="line">					break;</span><br><span class="line">				case XmlPullParser.START_TAG:</span><br><span class="line">					log(false, xmlBuilder, &quot;%s&lt;%s%s&quot;, sb, getNamespacePrefix(parser.getPrefix()), parser.getName());</span><br><span class="line">					sb.append(indentStep);</span><br><span class="line">					</span><br><span class="line">					int nameSpaceCountBefore = parser.getNamespaceCount(parser.getDepth() - 1);</span><br><span class="line">					int nameSpaceCount = parser.getNamespaceCount(parser.getDepth());</span><br><span class="line">					</span><br><span class="line">					for (int i = nameSpaceCountBefore; i != nameSpaceCount; i++) &#123;</span><br><span class="line">						log(xmlBuilder, &quot;%sxmlns:%s=\&quot;%s\&quot;&quot;, </span><br><span class="line">								i == nameSpaceCountBefore ? &quot;  &quot; : sb, </span><br><span class="line">										parser.getNamespacePrefix(i), parser.getNamespaceUri(i));</span><br><span class="line">					&#125;</span><br><span class="line">					</span><br><span class="line">					for (int i = 0, size = parser.getAttributeCount(); i != size; i++) &#123;</span><br><span class="line">						log(false, xmlBuilder, &quot;%s%s%s=\&quot;%s\&quot;&quot;, &quot; &quot;,</span><br><span class="line">								getNamespacePrefix(parser.getAttributePrefix(i)),</span><br><span class="line">								parser.getAttributeName(i),</span><br><span class="line">								getAttributeValue(parser, i));</span><br><span class="line">					&#125;</span><br><span class="line">					log(xmlBuilder, &quot;&gt;&quot;);</span><br><span class="line">					</span><br><span class="line">					break;</span><br><span class="line">				case XmlPullParser.END_TAG:</span><br><span class="line">					sb.setLength(sb.length() - indentStep.length());</span><br><span class="line">					log(xmlBuilder, &quot;%s&lt;/%s%s&gt;&quot;, sb,</span><br><span class="line">							getNamespacePrefix(parser.getPrefix()),</span><br><span class="line">							parser.getName());</span><br><span class="line">					break;</span><br><span class="line">				case XmlPullParser.TEXT:</span><br><span class="line">					log(xmlBuilder, &quot;%s%s&quot;, sb, parser.getText());</span><br><span class="line">					break;</span><br><span class="line">				default:</span><br><span class="line">					break;</span><br><span class="line">				&#125;</span><br><span class="line">				</span><br><span class="line">			&#125;</span><br><span class="line">			parser.close();</span><br><span class="line">		&#125; catch (Exception e) &#123;</span><br><span class="line">			e.printStackTrace();</span><br><span class="line">		&#125;</span><br><span class="line">		return xmlBuilder.toString();</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	/**</span><br><span class="line">	 * 把构造好的XML写入文件中</span><br><span class="line">	 */</span><br><span class="line">	public static void writeFormatXmlToFile(String content) &#123;</span><br><span class="line">		FileWriter fw = null;</span><br><span class="line">		try &#123;</span><br><span class="line">			fw = new FileWriter(&quot;xml/ApkParser_format.xml&quot;);</span><br><span class="line">			fw.write(content);</span><br><span class="line">		&#125; catch (Exception e) &#123;</span><br><span class="line">			e.printStackTrace();</span><br><span class="line">		&#125; finally &#123;</span><br><span class="line">			try &#123;</span><br><span class="line">				fw.close();</span><br><span class="line">			&#125; catch (IOException e) &#123;</span><br><span class="line">				e.printStackTrace();</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	/**</span><br><span class="line">	 * 获取属性</span><br><span class="line">	 * @param parser 解析器</span><br><span class="line">	 * @param index 标识</span><br><span class="line">	 * @return</span><br><span class="line">	 */</span><br><span class="line">	private static String getAttributeValue(AXmlResourceParser parser,int index) &#123;</span><br><span class="line">		int type=parser.getAttributeValueType(index);</span><br><span class="line">		int data=parser.getAttributeValueData(index);</span><br><span class="line">		if (type==TypedValue.TYPE_STRING) &#123;</span><br><span class="line">			return parser.getAttributeValue(index);</span><br><span class="line">		&#125;</span><br><span class="line">		if (type==TypedValue.TYPE_ATTRIBUTE) &#123;</span><br><span class="line">			return String.format(&quot;?%s%08X&quot;,getPackage(data),data);</span><br><span class="line">		&#125;</span><br><span class="line">		if (type==TypedValue.TYPE_REFERENCE) &#123;</span><br><span class="line">			return String.format(&quot;@%s%08X&quot;,getPackage(data),data);</span><br><span class="line">		&#125;</span><br><span class="line">		if (type==TypedValue.TYPE_FLOAT) &#123;</span><br><span class="line">			return String.valueOf(Float.intBitsToFloat(data));</span><br><span class="line">		&#125;</span><br><span class="line">		if (type==TypedValue.TYPE_INT_HEX) &#123;</span><br><span class="line">			return String.format(&quot;0x%08X&quot;,data);</span><br><span class="line">		&#125;</span><br><span class="line">		if (type==TypedValue.TYPE_INT_BOOLEAN) &#123;</span><br><span class="line">			return data!=0?&quot;true&quot;:&quot;false&quot;;</span><br><span class="line">		&#125;</span><br><span class="line">		if (type==TypedValue.TYPE_DIMENSION) &#123;</span><br><span class="line">			return Float.toString(complexToFloat(data))+</span><br><span class="line">				DIMENSION_UNITS[data &amp; TypedValue.COMPLEX_UNIT_MASK];</span><br><span class="line">		&#125;</span><br><span class="line">		if (type==TypedValue.TYPE_FRACTION) &#123;</span><br><span class="line">			return Float.toString(complexToFloat(data))+</span><br><span class="line">				FRACTION_UNITS[data &amp; TypedValue.COMPLEX_UNIT_MASK];</span><br><span class="line">		&#125;</span><br><span class="line">		if (type&gt;=TypedValue.TYPE_FIRST_COLOR_INT &amp;&amp; type&lt;=TypedValue.TYPE_LAST_COLOR_INT) &#123;</span><br><span class="line">			return String.format(&quot;#%08X&quot;,data);</span><br><span class="line">		&#125;</span><br><span class="line">		if (type&gt;=TypedValue.TYPE_FIRST_INT &amp;&amp; type&lt;=TypedValue.TYPE_LAST_INT) &#123;</span><br><span class="line">			return String.valueOf(data);</span><br><span class="line">		&#125;</span><br><span class="line">		return String.format(&quot;&lt;0x%X, type 0x%02X&gt;&quot;,data,type);</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	private static String getPackage(int id) &#123;</span><br><span class="line">		if (id&gt;&gt;&gt;24==1) &#123;</span><br><span class="line">			return &quot;android:&quot;;</span><br><span class="line">		&#125;</span><br><span class="line">		return &quot;&quot;;</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	/**</span><br><span class="line">	 * 获取前缀</span><br><span class="line">	 * @param prefix</span><br><span class="line">	 * @return</span><br><span class="line">	 */</span><br><span class="line">	private static String getNamespacePrefix(String prefix) &#123;</span><br><span class="line">		if (prefix==null || prefix.length()==0) &#123;</span><br><span class="line">			return &quot;&quot;;</span><br><span class="line">		&#125;</span><br><span class="line">		return prefix+&quot;:&quot;;</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	/**</span><br><span class="line">	 * 拼接字符串</span><br><span class="line">	 * @param xmlSb 字符串拼接器</span><br><span class="line">	 * @param format 格式化</span><br><span class="line">	 * @param arguments 参数</span><br><span class="line">	 */</span><br><span class="line">	private static void log(StringBuilder xmlSb,String format,Object...arguments) &#123;</span><br><span class="line">		log(true,xmlSb, format, arguments);</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	/**</span><br><span class="line">	 * 拼接字符串</span><br><span class="line">	 * @param newLine 是否为新行</span><br><span class="line">	 * @param xmlSb 字符串拼接器</span><br><span class="line">	 * @param format 格式化</span><br><span class="line">	 * @param arguments 参数</span><br><span class="line">	 */</span><br><span class="line">	private static void log(boolean newLine,StringBuilder xmlSb,String format,Object...arguments) &#123;</span><br><span class="line">		xmlSb.append(String.format(format, arguments));</span><br><span class="line">		if(newLine) xmlSb.append(&quot;\n&quot;);</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	// ILLEGAL STUFF, DONT LOOK :)</span><br><span class="line">	</span><br><span class="line">	public static float complexToFloat(int complex) &#123;</span><br><span class="line">		return (float)(complex &amp; 0xFFFFFF00)*RADIX_MULTS[(complex&gt;&gt;4) &amp; 3];</span><br><span class="line">	&#125;</span><br><span class="line">	</span><br><span class="line">	private static final float RADIX_MULTS[]=&#123;</span><br><span class="line">		0.00390625F,3.051758E-005F,1.192093E-007F,4.656613E-010F</span><br><span class="line">	&#125;;</span><br><span class="line">	private static final String DIMENSION_UNITS[]=&#123;</span><br><span class="line">		&quot;px&quot;,&quot;dip&quot;,&quot;sp&quot;,&quot;pt&quot;,&quot;in&quot;,&quot;mm&quot;,&quot;&quot;,&quot;&quot;</span><br><span class="line">	&#125;;</span><br><span class="line">	private static final String FRACTION_UNITS[]=&#123;</span><br><span class="line">		&quot;%&quot;,&quot;%p&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;,&quot;&quot;</span><br><span class="line">	&#125;;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<p>####参考文章<br><a href="https://blog.csdn.net/jiangwei0910410003/article/details/50568487" target="_blank" rel="noopener">Android逆向之旅—解析编译之后的AndroidManifest文件格式</a></p>
<p>####<a href="https://gitee.com/mazaiting/app_protection/tree/master/ParseAndroidManifest" target="_blank" rel="noopener">代码下载</a></p>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/blog/2018/08/06/Android-Plugin/Android-插件开发--类加载器/" rel="next" title="Android-插件开发--类加载器">
                <i class="fa fa-chevron-left"></i> Android-插件开发--类加载器
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/blog/2018/08/06/Android-Plugin/Android-解析DEX文件/" rel="prev" title="Android-解析DEX文件">
                Android-解析DEX文件 <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          

  



        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <img class="site-author-image" itemprop="image"
                src="/blog/images/avatar.jpeg"
                alt="凌浩雨" />
            
              <p class="site-author-name" itemprop="name">凌浩雨</p>
              <p class="site-description motion-element" itemprop="description">专业从事于移动端开发，Android与iOS均有涉及，主做Android开发与React Native开发</p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">393</span>
                  <span class="site-state-item-name">posts</span>
                </a>
              </div>
            

            

            

          </nav>

          

          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2018</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">凌浩雨</span>

  
</div>


  <div class="powered-by">Powered by <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a></div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">Theme &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Pisces</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  


  <script type="text/javascript" src="/blog/js/src/affix.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/schemes/pisces.js?v=5.1.4"></script>



  
  <script type="text/javascript" src="/blog/js/src/scrollspy.js?v=5.1.4"></script>
<script type="text/javascript" src="/blog/js/src/post-details.js?v=5.1.4"></script>



  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
